﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;

namespace Quiz_for_da_IT
{
    class QuestionsList
    {
        //public int numberOfQuestions
        //{
        //    get;
        //    set;
        //}

        string[] questions = File.ReadAllLines(@"../../Questions List.txt");

       
        public UIElement ShowQuestionsList()
        {
            var stackPanel = new StackPanel();

            //Generete buttons for each question
            for (int i = 0; i < questions.Length; i++)
            {
                const int buttonHeight = 25;
                var questionButton = new Button();
                questionButton.Height = buttonHeight ;
                questionButton.Content = "Question # " + i.ToString();
                questionButton.Tag = i;

                //Implement an event handler for the Click event
                questionButton.Click += new RoutedEventHandler(ButtonClickOneEvent);
                //Add the button to a stack panel which will be later added to the main one
                stackPanel.Children.Add(questionButton);
            }

            return stackPanel;
        }

        //Since all buttons are using the same Click Event, a Tag is added to every newly created button and then using this
        //tag each button can be assigned a specific event
        private void ButtonClickOneEvent(object sender, EventArgs e)
        {
            var currButton = sender as Button;

            MessageBox.Show(questions[(int)currButton.Tag].ToString());
        }



    }
}
